package com.penghaisoft.microwms.material.web.insidewarehouse.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.penghaisoft.microwms.common.data.model.MdContract;
import com.penghaisoft.microwms.common.dto.Resp;
import com.penghaisoft.microwms.common.page.Pager;
import com.penghaisoft.microwms.common.service.BaseService;
import com.penghaisoft.microwms.common.wms.model.RawContractChangePlanSn;
import com.penghaisoft.microwms.material.web.insidewarehouse.dao.RawContractChangePlanSnMapper;
import com.penghaisoft.microwms.material.web.insidewarehouse.service.IRawContractChangePlanSnService;

/** 
 * @Package com.penghaisoft.microwms.material.web.insidewarehouse.service.impl
 * @ClassName: RawContractChangePlanSnServiceImpl
 * @Description: 原材料合同更改明细表
 * @author luoteng
 * @date 2019年3月7日 下午1:09:52
 */
@Service("rawContractChangePlanSnService")
public class RawContractChangePlanSnServiceImpl extends BaseService implements IRawContractChangePlanSnService{
		@Resource
		private RawContractChangePlanSnMapper rawContractChangePlanSnMapper;
		
	  /**
	   * 新增记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp create(RawContractChangePlanSn rawContractChangePlanSn){
			rawContractChangePlanSnMapper.create(rawContractChangePlanSn);
			return success();
		}

	  /**
	   * 删除记录（逻辑删除）
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp delete(RawContractChangePlanSn rawContractChangePlanSn){
			rawContractChangePlanSnMapper.delete(rawContractChangePlanSn);
			return success();
		}
		
	  /**
	   * 查询列表
	   * @param pager
	   * @param baseResource
	   * @return
	   */
		@Override
		public Pager<RawContractChangePlanSn> findListByCondition(int page, int rows,RawContractChangePlanSn condition){
		    Pager<RawContractChangePlanSn> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
    		condition.preQuery();
			List<RawContractChangePlanSn> records = rawContractChangePlanSnMapper.queryList(pager,condition);
			long size = rawContractChangePlanSnMapper.queryCount(condition);
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

	  /**
	   * 查询单条
	   * @param id
	   * @return
	   */
		@Override
		public RawContractChangePlanSn findById(String id){
			return rawContractChangePlanSnMapper.queryById(id);
		}
		
	  /**
	   * 修改记录
	   * @param baseResource
	   * @return
	   */
		@Override
		public Resp update(RawContractChangePlanSn rawContractChangePlanSn){
			rawContractChangePlanSnMapper.updateBySelect(rawContractChangePlanSn);
			return success();
		}
		
		public List<RawContractChangePlanSn> getJYHZ(RawContractChangePlanSn rawContractChangePlanSn) {
			return rawContractChangePlanSnMapper.queryJYHZ(rawContractChangePlanSn);
		}
		
		public Pager<RawContractChangePlanSn> getJYHZInfo(int page, int rows, RawContractChangePlanSn rawContractChangePlanSn) {
			Pager<RawContractChangePlanSn> pager = new Pager<>();
		    pager.setPage(page);
		    pager.setRows(rows);
		    
		    long size = rawContractChangePlanSnMapper.queryJYHZInfoCount(rawContractChangePlanSn);
			List<RawContractChangePlanSn> records = new ArrayList<RawContractChangePlanSn>();
			if (size > 0) {
				records = rawContractChangePlanSnMapper.queryJYHZInfoList(pager, rawContractChangePlanSn);
			}
			pager.setRecords(records);
			pager.setTotalCount(size);
			return pager;
		}

}
